package com.frxuexi.mynews.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_commom.GlideUtils
import com.frxuexi.mynews.R
import com.frxuexi.mynews.entity.NewsEntity

class MyNewsAdapter:BaseMultiItemQuickAdapter<NewsEntity,BaseViewHolder>() {

    init {
        addItemType(0,R.layout.item_news)
        addItemType(1,R.layout.item_news2)
    }


    override fun convert(helper: BaseViewHolder, item: NewsEntity) {
        if (helper.itemViewType==0){
            helper.setText(R.id.news_title,item.title)
            helper.setText(R.id.news_love,item.looks.toString())
            GlideUtils.loadRoundImage(context,item.imgurl,helper.getView<ImageView>(R.id.news_ivleft))
            GlideUtils.loadRoundImage(context,item.imgurl,helper.getView<ImageView>(R.id.news_ivmiddle))
            GlideUtils.loadRoundImage(context,item.imgurl,helper.getView<ImageView>(R.id.news_ivright))
        }else{
            helper.apply {
                setText(R.id.news_title2,item.title)
                setText(R.id.news_love2,item.looks.toString())
                GlideUtils.loadRoundImage(context,item.imgurl,helper.getView<ImageView>(R.id.news_iv))
            }
        }
    }
}